from zhipuai import ZhipuAI
import anaylize
import json
import requests
# 这个api是根据公司注册信息某个字段是某个值来查询具体的公司名称
client = ZhipuAI(api_key="8fb21e517a965b10cf87b7fdadf18a74.UVLbxTJXdL3YLxcT") # 请填写您自己的APIKey
# 先获取公司名称
tools = [
    {
        "type": "function",
        "function": {
            "name": "search_company_name_by_register",
            "description": "根据公司注册信息某个字段是某个值来查询具体的公司名称",
            "parameters": {
                "type": "object",
                "properties": {
                    "key": {
                        "type": "string",
                        "description": "基本字段",
                    },
                    "value": {
                        "type": "string",
                        "description": "基本字段的值",
                    }
                },
                "required": ["key","value"],
            },
        }
    }
]

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer DE32EB46D23350E0B75B3702C8D5DC036F8CE32DC73C919D'
}
# 下面的代码根据获得的key和value和tools里面的api名称来获取公司的名字

domain = "comm.chatglm.cn"
url = f"https://{domain}/law_api/search_company_name_by_register"

data = {
    # "key": "{}",
    # "value": "{}"
    "key": "注册编号",
    "value": "450200000031278"
}

rsp = requests.post(url, json=data, headers=headers)
print(rsp.json())
